class IUP_BACKGROUND_BOX
-- Creates a simple native container with no decorations. Useful for 
-- controlling children visibility for IUP_ZBOX or IUP_EXPANDER.
-- The box can be created with no elements and be dynamic filled using 
-- "append" or "insert".
	
inherit
	IUP_CANVAS
		redefine
			set_border,
			set_can_focus
		end
	IUP_WIDGET_CLIENTSIZE
	IUP_WIDGET_CLIENTOFFSET
	IUP_WIDGET_DECORATION
	IUP_WIDGET_BGCOLOR
	IUP_WIDGET_BACK_IMAGE_0


create {ANY}
	background_box_empty,
	background_box


feature {ANY}

	background_box_empty
		local
			a_background_box, p: POINTER
		do
			a_background_box := int_background_box (p)
			set_widget(a_background_box)
		end

	background_box (child: IUP_WIDGET)
		local
			a_background_box: POINTER
		do
			a_background_box := int_background_box (child.widget)
			set_widget(a_background_box)
		end

	-- Commands to handle attributes
	
	set_border (state: BOOLEAN)
		-- (creation only): the default value is "False".
		do
			Precursor(state)
		end

	has_border: BOOLEAN
		-- Return if the element has border.
		local
			str: STRING
		do
			str := iup_open.get_attribute(Current, "BORDER")
			Result := yesno_to_boolean(str)
		end

	set_canvas_box (state: BOOLEAN)
		-- (non inheritable): enable the behavior of a canvas box instead of a 
		-- regular container. Default: "False".
		do
			iup_open.set_attribute(Current, "CANVASBOX", boolean_to_yesno(state))
		end

	set_child_offset (dx, dy: INTEGER)
		-- Allow to specify a position offset for the child. Available for native 
		-- containers only. It will not affect the natural size, and allows to 
		-- position controls outside the client area. Format "dxxdy", where dx 
		-- and dy are integer values corresponding to the horizontal and vertical 
		-- offsets, respectively, in pixels. Default: 0x0.
		require
			non_negative: dx >= 0
							  dy >= 0
		local
			size: STRING
		do
			size := dx.to_string
			size.append_string("x")
			size.append_string(dy.to_string)

			iup_open.set_attribute(Current, "CHILDOFFSET", size)
		end

	get_child_offset: TUPLE[INTEGER, INTEGER]
		-- The child offset.
		local
			offset: STRING
		do
			offset := iup_open.get_attribute(Current, "CHILDOFFSET")
			Result := components_of_size(offset)
		end

	set_can_focus (state: BOOLEAN)
		-- Default: False.
		do
			Precursor (state)
		end

feature {}

	-- Internals

	int_background_box (child: POINTER): POINTER
		external "plug_in"
      alias "{
         location: "${sys}/plugins"
         module_name: "iup"
         feature_name: "IupBackgroundBox"
         }"
      end

end

-- The MIT License (MIT)

-- Copyright (c) 2016, 2017, 2019 by German A. Arias

-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in 
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.






	
